package com.ibeeking.found.msg.rest.controller.v1;


import com.ibeeking.found.common.annotation.LoginUser;
import com.ibeeking.found.common.entity.CurrentUser;
import com.ibeeking.found.msg.rest.service.IWxMpTagsService;
import com.ibeeking.found.msg.service.common.param.WxMpTagsParam;
import com.ibeeking.found.msg.service.common.query.WxMpTagsPageQuery;
import com.ibeeking.found.msg.service.common.query.WxMpTagsQuery;
import com.ibeeking.found.msg.service.common.vo.WxMpTagsVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 公众号标签，已弃用
 * @ClassName WxmpTitleController控制器
 * @Description
 * @Author ibeeking
 * @Date 2020-12-28 09:52
 **/
@Deprecated
@RestController
@RequestMapping("/b/wxMp/tags/v1")
public class WxMpTagsController {

    @Resource
    private IWxMpTagsService wxmpTitleService;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询标签列表")
    @PostMapping(value = "/list")
    public List<WxMpTagsVO> list(@RequestBody WxMpTagsQuery wxMpTagsQuery) {
        return wxmpTitleService.list(wxMpTagsQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "分页查询标签")
    @PostMapping(value = "/pageList")
    public Page<WxMpTagsVO> pageList(@RequestBody WxMpTagsPageQuery wxmpTagsPageQuery) {
        return wxmpTitleService.pageList(wxmpTagsPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存标签")
    @PostMapping(value = "/add")
    public Boolean add(@LoginUser CurrentUser currentUser, @RequestBody @Validated(BaseValidationGroup.Insert.class) WxMpTagsParam wxMpTagsParam) {
    	wxMpTagsParam.setModifyBy(currentUser.getId()).setCreateBy(currentUser.getId());
        return wxmpTitleService.add(wxMpTagsParam);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改标签")
    @PostMapping(value = "/modify")
    public Boolean modify(@LoginUser CurrentUser currentUser,@RequestBody @Validated(BaseValidationGroup.Update.class) WxMpTagsParam wxMpTagsParam) {
        wxMpTagsParam.setModifyBy(currentUser.getId());
        return wxmpTitleService.modify(wxMpTagsParam);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看标签详情")
    @GetMapping(value = "/view/{id}")
    public WxMpTagsVO view(@PathVariable("id") Long id) {
        return wxmpTitleService.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除标签")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return wxmpTitleService.del(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "租户发布状态")
    @GetMapping(value = "/changeStatus/{id}/{status}")
    public Boolean changeStatus(@LoginUser CurrentUser currentUser, @PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return wxmpTitleService.changeStatus(id, status, currentUser.getId());
    }
}
